(define (mark-leaves-with-red-depth bintree)
    (double-tree 0 bintree)
)

(define (double-tree reds bintree)
    (cond 
        ((integer? bintree) reds)
        (
            (eqv? (car bintree) `red)
            (append
                (list (car bintree))
                (list (double-tree (+ reds 1) (cadr bintree)))
                (list (double-tree (+ reds 1) (caddr bintree)))
            )
        )
        (else
            (append
                (list (car bintree))
                (list (double-tree reds (cadr bintree)))
                (list (double-tree reds (caddr bintree)))
            )
        )
    )
)

(display
    (mark-leaves-with-red-depth
        `(red
            (red 1 (quux 1 2))
            (bar 4 5)
        ) 
    )
)
